package com.augurit.agmobile.agwater5.drainage.supervise.view

import android.os.Bundle
import android.view.LayoutInflater
import android.view.ViewGroup
import com.augurit.agmobile.agwater5.drainage.common.constant.StringConstant
import com.augurit.agmobile.agwater5.drainage.supervise.adapter.SuperviseVariousModuleAdapter
import com.augurit.agmobile.agwater5.drainage.supervise.model.SuperviseType
import com.augurit.agmobile.agwater5.drainage.supervise.model.SuperviseVariousModuleBean
import com.augurit.agmobile.agwater5.drainage.supervise.model.SuperviseVariousTab
import com.example.arm.base.BaseFragment
import com.example.drainage.databinding.FragmentSuperviseVariousBinding

/**
 * @author 创建人 ：yanghaozhang
 * @version 1.0
 * @package 包名 ：com.augurit.agmobile.agwater5.drainage.supervise.view
 * @createTime 创建时间 ：2022/1/5
 * @modifyBy 修改人 ：
 * @modifyTime 修改时间 ：
 * @modifyMemo 修改备注：
 */
class SuperviseVariousFragment : BaseFragment<FragmentSuperviseVariousBinding>() {

    private var facilityType: SuperviseType = SuperviseType.Reservoir

    private var tab: SuperviseVariousTab = SuperviseVariousTab.SafeManager

    private var id: String? = null

    private val adapter = SuperviseVariousModuleAdapter()

    companion object {
        fun getInstance(facilityType: SuperviseType, id: String, tab: SuperviseVariousTab): SuperviseVariousFragment {
            return SuperviseVariousFragment().apply {
                arguments = Bundle().apply {
                    putSerializable(StringConstant.KEY_TYPE, facilityType)
                    putString(StringConstant.KEY_ID, id)
                    putSerializable(StringConstant.KEY_NAME, tab)
                }
            }
        }
    }

    override fun initView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): FragmentSuperviseVariousBinding {
        return FragmentSuperviseVariousBinding.inflate(inflater)
    }

    override fun initData(savedInstanceState: Bundle?) {
        initIntent()
        initView()
        initViewModel()
        initData()
    }

    //-----------------已定义方法---------------------------
    private fun initIntent() {
        facilityType = arguments?.getSerializable(StringConstant.KEY_TYPE) as SuperviseType
        id = arguments?.getString(StringConstant.KEY_ID)
        tab = arguments?.getSerializable(StringConstant.KEY_NAME) as SuperviseVariousTab
    }

    private fun initView() {
        binding?.apply {
            recyclerView.adapter = adapter

            when (tab) {
                SuperviseVariousTab.SafeManager -> {
                    adapter.setNewInstance(
                        mutableListOf(
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,2),
                            SuperviseVariousModuleBean("防汛“三个责任人”落实情况",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,2),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                        )
                    )
                }
                SuperviseVariousTab.EngineeringDefect -> {
                    adapter.setNewInstance(
                        mutableListOf(
                            SuperviseVariousModuleBean("防汛“三个责任人”落实情况111",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                            SuperviseVariousModuleBean("综合管理111",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                            SuperviseVariousModuleBean("综合管理",2,5,1),
                        )
                    )
                }
            }
        }
    }

    private fun initViewModel() {

    }

    private fun initData() {

    }

}